package com.heima.admin.gateway;

import com.heima.model.admin.pojos.AdUser;
import com.heima.utils.common.JwtUtils;
import com.heima.utils.common.Payload;
import com.heima.utils.common.RsaUtils;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Value;

import java.security.PublicKey;

public class gatewaytest {
   public String publicKeyPath = "F:\\key\\rsa\\rsa-key.pub";
    public String privateKeyPath = "F:\\key\\rsa\\rsa-key";
    @Test
    public void jwstest(){
        PublicKey publicKey = null;
        try {
            publicKey = RsaUtils.getPublicKey(publicKeyPath);
            System.out.println(publicKey);
        } catch (Exception e) {
            e.printStackTrace();
        }
        String token ="eyJhbGciOiJSUzI1NiJ9.eyJ1c2VyIjoie1wiaWRcIjoyLFwibmFtZVwiOlwiYWRtaW5cIixcInBhc3N3b3JkXCI6bnVsbCxcInNhbHRcIjpcIjEyM2FiY1wiLFwibmlja25hbWVcIjpcImFkXCIsXCJpbWFnZVwiOm51bGwsXCJwaG9uZVwiOlwiMTMzMjAzMjU1MjhcIixcInN0YXR1c1wiOjEsXCJlbWFpbFwiOlwiYWRtaW5AcXEuY29tXCIsXCJsb2dpblRpbWVcIjp7XCJtb250aFwiOlwiTUFSQ0hcIixcInllYXJcIjoyMDIwLFwiZGF5T2ZNb250aFwiOjQsXCJob3VyXCI6MTcsXCJtaW51dGVcIjo3LFwibW9udGhWYWx1ZVwiOjMsXCJuYW5vXCI6MCxcInNlY29uZFwiOjM3LFwiZGF5T2ZXZWVrXCI6XCJXRURORVNEQVlcIixcImRheU9mWWVhclwiOjY0LFwiY2hyb25vbG9neVwiOntcImlkXCI6XCJJU09cIixcImNhbGVuZGFyVHlwZVwiOlwiaXNvODYwMVwifX0sXCJjcmVhdGVkVGltZVwiOntcIm1vbnRoXCI6XCJNQVJDSFwiLFwieWVhclwiOjIwMjAsXCJkYXlPZk1vbnRoXCI6NCxcImhvdXJcIjoxNyxcIm1pbnV0ZVwiOjcsXCJtb250aFZhbHVlXCI6MyxcIm5hbm9cIjowLFwic2Vjb25kXCI6NDAsXCJkYXlPZldlZWtcIjpcIldFRE5FU0RBWVwiLFwiZGF5T2ZZZWFyXCI6NjQsXCJjaHJvbm9sb2d5XCI6e1wiaWRcIjpcIklTT1wiLFwiY2FsZW5kYXJUeXBlXCI6XCJpc284NjAxXCJ9fX0iLCJqdGkiOiJPRGxrTm1Oa05qUXRPVFJsWlMwME5UbG1MVGhoTkRFdE1qYzRaV1kxWm1ObU0yWXgiLCJleHAiOjE2MjgxODY2NjJ9.L445v0V2G4WHKayj0f4IpDhYrIbZTFZuX7N0M3BFHPvH8CTn3Pswr2_gBpIXSwQbRvDLYRVxqqVgGVpBUQ48Nk7jEpg8Z5DP5aQMN96Kb9DxFplxLyl0D3jsUyfTLUXWtURHVUQmAL2GDm4cZCu524nwOU2Yt2QfnlyR0Wcrr9kPGonn77DhmrE915P-ru-nVhPFLVFpJ0sACAksMLpfJf08nC6CVrDOPO8ceAXUA9R1KjTmL9Si3aOa5no3FyVdn0RVO9OwqrW4_rhGRqkOZRBjAiIjEXUvSxjp42sHoVHuAkR2_ir8zzFSjn19fhr2EnMKBNY9J-tEVpFYojqs_Q" ;
        Payload<AdUser> payload = JwtUtils.getInfoFromToken(token, publicKey, AdUser.class);

        AdUser adUser = payload.getInfo();
        String password = adUser.getPassword();
        System.out.println(password);
    }
}
